package puzzle.projecteuler.p100;

import java.util.Arrays;

import astudy.util.AdvMath;

public class Problem050 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		int max = 1000000;
		Integer[] ps = AdvMath.primes(max);
		int maxLen = 0;
		int p = 2;
		for (int i = 0; i < ps.length; i ++) {
			int sump = ps[i];
			int len = 1;
			for (int j = i+1; j < ps.length && sump < max; j ++) {
				if (len > maxLen && Arrays.binarySearch(ps, sump) >= 0) {
					maxLen = len;
					p = sump;
				}
				sump += ps[j];
				len ++;
			}
		}
		System.out.println(maxLen);
		System.out.println(p);
	}
}
